<?php

class Activity extends BaseModel
{
    public $map;
    public $reduce;
    public $jar;

    public $mapred_type;
    
	/**
	 * Returns the static model of the specified AR class.
	 * @return CActiveRecord the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'activity';
	}

    public function rules()
    {
        if($this->activity_type == ActivityType::MapRed) {
            $require = 'activity_name, activity_type, retry_times';
        }
        else {
            $require = 'activity_name, activity_type, programs, retry_times';
        }
        return array(
            array($require, 'required', 'message'=>'{attribute} 不能为空'),
            array('activity_name', 'unique'),    
        );
    }

    /**
     * 
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'activity_id'   =>  '编号',
            'activity_name' =>  '活动名',
            'activity_type' =>  '类型',
            'mapred_type'   =>  'MapRed类型',
            'programs'      =>  '程序',
            'jar'           =>  'Jar包',
            'map'           =>  'Map程序',
            'reduce'        =>  'Reduce程序',
            'retry_times'   =>  '重试次数',
            'inputs'        =>  '输入',
            'outputs'       =>  '输出',
            'input_format'  =>  '输入格式',
            'output_format' =>  '输出格式',
            'partitioner'   =>  '分区方式',
            'params'        =>  '其它参数',
        );
    }
}
